import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-08-15
 * Time: 13:47
 */
public class demo8 {
    public static void main(String[] args) {
        try (OutputStream outputStream = new FileOutputStream("./test.txt", true)) {
            outputStream.write(97);
            outputStream.write(98);
//            outputStream.write(byte[] b,int off,int len);写入字节数组的某一空间,[off,off+len)的范围
//            outputStream.write(int b);写入1个字节
//            outputStream.write(byte[] b);//写入一个字节数组
            //write:写操作,会把文件之前的内容清空,不是追加,
            //使用OutputStream打开文件,之前内容就没了,new OutputStream对象的时候可以传参true,利用解决这个问题而且可以追加
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
